package by.grsu.coctails.db.tables;

import android.content.ContentValues;
import android.database.Cursor;
import by.grsu.coctails.model.db.CoctailsCategoryRelationDb;

public class CoctailsCategoryRelationTable {

	public static final String NAME = "Coctails_Category_Relation";

	private static final String[] COCTAILS_CATEGORY_RELATION_COLUMNS = { "ID",
			"CoctailID", "CategoryID" };

	public static final Integer ID_COLUMN_INDEX = 0;
	public static final String ID_COLUMN = COCTAILS_CATEGORY_RELATION_COLUMNS[ID_COLUMN_INDEX];

	public static final Integer COCTAIL_ID_COLUMN_INDEX = 1;
	public static final String COCTAIL_ID_COLUMN = COCTAILS_CATEGORY_RELATION_COLUMNS[COCTAIL_ID_COLUMN_INDEX];

	public static final Integer CATEGORY_ID_COLUMN_INDEX = 2;
	public static final String CATEGORY_ID_COLUMN = COCTAILS_CATEGORY_RELATION_COLUMNS[CATEGORY_ID_COLUMN_INDEX];

	public static ContentValues getContentValues(
			CoctailsCategoryRelationDb relation) {
		ContentValues contentValues = new ContentValues();
		contentValues.put(COCTAIL_ID_COLUMN, relation.getCoctailId());
		contentValues.put(CATEGORY_ID_COLUMN, relation.getCategoryId());

		return contentValues;
	}

	public static CoctailsCategoryRelationDb getCoctailCategoryRelation(
			Cursor cursor) {
		long coctailId = cursor.getInt(COCTAIL_ID_COLUMN_INDEX);
		long categoryId = cursor.getInt(CATEGORY_ID_COLUMN_INDEX);

		return new CoctailsCategoryRelationDb(coctailId, categoryId);
	}

}
